<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的盐汽水</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/binge.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header" style="height: 0.9rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <header class="header header-shadow">
        <div class="header-left">
            <div tapmode onclick="comeBack();" class="nav-left"><img class="icon-back" src="../../icon/icon-back.png"/>
            </div>
        </div>
        <h2>我的盐汽水</h2>
        <div class="header-right">
            <div tapmode onclick="commonUrl('myScore_details')" class="nav-right">积分明细</div>
        </div>
    </header>
</div>

<div class="mescroll" id="mescroll" style="padding-top: 1.6rem">
    <section class="html_section ">
       <div class="score_bg pr30 pl30">
            <div class="c-fff mt50">总获取毫升</div>
            <div class="c-fff f60" id="all_integral"></div>
            <div class="member_box pl40 pr40">
                <span>今日获得盐汽水</span>
                <span id="todayScore" class="c-primary f30"><em id="tody_integral"></em>ml</span>
            </div>
       </div>
       <div class="pl30 pr30 pt70 mt20">
           <div class="score_Title">获取盐汽水</div>
           <ul class="today_list" id="today_list">
               <!--<li class="pt40 bb pb40">
                    <div>
                        <div class="f32 b">登录</div>
                        <div class="c-999 f24 mt15">每日首次登陆</div>
                        <div class="line_center mt10"><div class="score_jd" ><span style="width: 85%"></span></div><span class="f24 ml5 c-999">已获得1分/每日上限1分</span></div>
                    </div>
                    <div class="today_1"></div>
               </li>
               <li class="pt40 bb pb40">
                    <div>
                        <div class="f32 b">登录</div>
                        <div class="c-999 f24 mt15">每日首次登陆</div>
                        <div class="line_center mt10"><div class="score_jd" ><span style="width: 85%"></span></div><span class="f24 ml5 c-999">已获得1分/每日上限1分</span></div>
                    </div>
                    <div class="today_2"></div>
               </li>-->
           </ul>
       </div>

    </section>
</div>

<!-- 右上角操作 -->
<div class="action-model model" tapmode onclick="closeModel()">
    <div class="action-view" tapmode onclick="stopModel(event)">
        <h6 class="shareTitle">分享</h6>
        <a href="javascript:void(0);" tapmode onclick="closeModel(event)" class="model-close"></a>
        <div class="model-detail">
            <ul>
                <li tapmode onclick="shareWx(event)" class="threeShare">
                    <div class="share-icon icon1"></div>
                    <p>微信</p>
                </li>
                <li tapmode onclick="shareWxq(event)" class="threeShare">
                    <div class="share-icon icon2"></div>
                    <p>朋友圈</p>
                </li>
                <li tapmode onclick="shareQq(event)" class="threeShare">
                    <div class="share-icon icon3"></div>
                    <p>QQ</p>
                </li>
                <li tapmode onclick="shareQzone(event)" class="threeShare">
                    <div class="share-icon icon4"></div>
                    <p>QQ空间</p>
                </li>
                <li tapmode onclick="shareWb(event)" class="threeShare">
                    <div class="share-icon icon5"></div>
                    <p>微博</p>
                </li>
                <li tapmode class="copy" onclick="copyLink()">
                    <div class="share-icon icon-copy"></div>
                    <p>复制链接</p>
                </li>
            </ul>
        </div>
        <!--<div class="shade-user">
            <a href="javascript:void(0);" class="shade-btn"><span>屏蔽此人</span></a>
        </div>-->
    </div>
</div>
<!-- 右上角操作 end -->

</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/mescroll.min.css"/>
<script type="text/javascript" src="../../script/mescroll.min.js"></script>
<script type="text/javascript">

    var _model = $(".model");
    var shareTitle = '大学情报局';//分享title
    var shareInfo = '助力你的大学生活';//分享info
    var shareImg = 'widget://icon/logo.png';//分享图片
    var shareLink = '';//分享链接
    var shareStatus = '',
    apiready = function () {
        setFixStatusBar(); //设置状态栏
        pop.loading();
        keybackListener()

        SystemCheckVersion(1);


        get_integral();


    }

    function get_integral() {
        var param = {
            token: $api.getStorage('token')
        }
        getAjax(Interface.get_integral,param,function (res) {
            console.log(jsonChange(res))
            var top = res.data.top;
            if(isDefine(top)){

                $('#all_integral').html(top.all_integral+'ml');
                $('#tody_integral').html(top.tody_integral);

            }
            var rule = res.data.rule;
            if(isDefine(rule)){
                var list = '';
                var flag = false;
                $.each(rule,function (i, item) {

                    var rate = '';
                    if(item.number != 0){
                        var count = Number(item.integral) * Number(item.number);
                        var countRate = item.member_get_integral/count * 100 + '%';
                        rate = '<span style="width: '+countRate+'"></span>'
                    }else {
                        rate = '<span style="width: 100%"></span>'
                    }

                    var today_status = '';
                    if(item.integral_status == 2){
                        if(item.id == 6){
                            today_status = '<div class="today_2" tapmode onclick=\'commonUrl("../circle/circle")\'></div>'
                        }else {
                            today_status = '<div class="today_2" tapmode onclick=\'commonUrl("../index/index")\'></div>'
                        }

                        if(item.id == 8 || item.id == 9){
                            today_status = ''
                        }else if(item.id == 10){
                            today_status = '<div class="today_3" tapmode onclick=\'commonUrl("../member/tougao")\'></div>'
                        }else if(item.id == 11){
                            today_status = '<div class="today_2" tapmode onclick=\'commonUrl("../match/match_index")\'></div>'
                        }else if(item.id == 12){
                            today_status = '<div class="today_5" tapmode onclick=\'openModel(1)\'></div>'
                        }else if(item.id == 2){
                            today_status = '<div class="today_4" tapmode onclick=\'openModel(2)\'></div>'
                        }
                    }else if(item.integral_status == 1){
                        today_status = '<div class="today_1"></div>'

                        if(item.id == 8 && item.integral_status == 1){
                            today_status = ''
                            flag = true;
                        } if(item.id == 12 && item.integral_status == 1){
                            today_status = '<div class="today_5" tapmode onclick=\'openModel(1)\'></div>'
                        }
                    }
                    var listClass = 'list'+item.id;
                    list +='<li class="pt40 bb pb40 '+listClass+'">' +
                        '                    <div>' +
                        '                        <div class="f32 b">'+item.title+'</div>' +
                        '                        <div class="c-999 f24 mt15">'+item.explain+'</div>' +
                        '                        <div class="line_center mt10">' +
                        '                           <div class="score_jd" >'+ rate +'</div>' +
                        '                           <span class="f24 ml5 c-999">已获得<em>'+item.member_get_integral+'</em>ml/'+item.content+'</span>' +
                        '                       </div>' +
                        '                    </div>'+today_status+'</li>'

                })
                // console.log(list)
                $("#today_list").html(list)
                if(flag){
                    $(".list7").find('.today_2').hide();
                }

            }
            pop.close()
            mescroll.endErr()
        },function (error) {
            pop.notice(error.msg)
            pop.close()
            mescroll.endErr()
        })
    }


    function getShareLinks() {
        var param = {
            token: $api.getStorage('token')
        }
        getAjax(Interface.share_app,param,function (res) {

            if(isDefine(res.data)){
                shareLink = res.data.url;
            }
        },function (error) {

        })

    }

    function getInviteLinks() {
        var param = {
            token: $api.getStorage('token')
        }
        getAjax(Interface.share_login,param,function (res) {

            if(isDefine(res.data)){
                shareLink = res.data.url;
            }
        },function (error) {

        })

    }



    //创建MeScroll对象
    var mescroll = new MeScroll("mescroll", {
        down: {
            auto: false, //是否在初始化完毕之后自动执行下拉回调callback; 默认true
            callback: downCallback //下拉刷新的回调
        }
    });
    /*下拉刷新的回调 */
    function downCallback() {

        get_integral()

        //mescroll.endErr();
    }

    //开启弹窗
    function openModel(type) {

        if(type == 1){
            shareStatus = 1;
            getShareLinks()
        }else {
            getInviteLinks()
        }
        _model.addClass('showModel');
        setTimeout(function () {
            _model.find('.action-view').addClass('showView');
        }, 10)
    }

    //阻止事件冒泡
    function stopModel(event) {
        event.stopPropagation();
    }

    //关闭弹窗
    function closeModel(event) {
        if (event) {
            event.stopPropagation();
        }
        _model.find('.action-view').removeClass('showView');
        setTimeout(function () {
            _model.removeClass('showModel');
        }, 500)
    }

    function copyLink() {
        var text = shareLink;
        copy(text);
    }


    //scene:session（会话）timeline（朋友圈）favorite（收藏）
    //title:标题
    //thumb 图标
    //contentUrl 分享的地址
    //type：1新闻 2帖子 3赛况 4活动

    //微信好友分享
    function shareWx(){
        var p = {
            apiKey: '',
            scene: 'session',
            title: shareTitle,
            thumb: shareImg,
            contentUrl: shareLink
        };
        wxpyqFX(p,shareStatus);
    }
    //朋友圈
    function shareWxq(){
        var p = {
            apiKey: '',
            scene: 'timeline',
            title: shareTitle,
            thumb: 'widget://icon/logo22.png',
            contentUrl: shareLink
        };
        wxpyqFX(p,shareStatus);
    }
    //qq好友
    function shareQq(){
        var p = {
            url: shareLink,
            title: shareTitle,
            description: shareInfo,
            imgUrl: shareImg,
            type:'QFriend'
        }
        qqfx(p,shareStatus);
    }

    //qq空间
    function shareQzone(){
        var p = {
            url: shareLink,
            title: shareTitle,
            description: shareInfo,
            imgUrl: shareImg,
            type:'QZone'
        }
        qqfx(p,shareStatus);
    }

    //微博
    function shareWb(){
        var p = {
            apiKey: '',
            scene: 'session',
            title: shareTitle,
            description: shareInfo,
            thumb: shareImg,
            contentUrl: shareLink,
        };
        weibo_authorize(p,shareStatus);
    }


</script>
